Namespace - LJCDataAccess
Parameters
sql - The Select SQL statement.
tableMapping - The table map collection.
Returns
A reference to the
DataSet
object.
Syntax
C# |
public DataSet GetDataSet(String sql, DataTableMappingCollection tableMapping = null)
|
Executes a Select statement and retrieves the
DataSet
object.
(E)
Example
C# |
private static void GetDataSet(DataAccess dataAccess)
{
string sql = "select * from firstTable; select * from secondTable";
TableMapping tableMapping = new TableMapping();
tableMapping.AddTableMap("FirstTable");
tableMapping.AddColumnMap("FirstTable", "OriginalName", "NewName");
tableMapping.AddTableMap("SecondTable");
tableMapping.AddColumnMap("SecondTable", "OriginalName", "NewName");
var dataSet = dataAccess.GetDataSet(sql, tableMapping.TableMaps);
if (dataSet != null)
{
var dataTable = dataSet.Tables["FirstTable"];
if (dataTable != null)
{
foreach (DataRow dataRow in dataTable.Rows)
{
for int index = 0; index < dataTable.Columns.Count; index++)
{
string value = dataRow[index].ToString();
}
}
}
dataTable = dataSet.Tables["SecondTable"];
if (dataTable != null)
{
foreach (DataRow dataRow in dataTable.Rows)
{
for int index = 0; index < dataTable.Columns.Count; index++)
{
string value = dataRow[index].ToString();
}
}
}
}
}
|
Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.